#include <bits/stdc++.h>

using namespace std;
int getnext( string s,int next[] );
int main(){
	int len,len1,len2,i,j;
	
	string s1,s2;
	int n;
	cin>>n;
	while( n-- ){
		cin>>s1>>s2;
		i = j = 0;
		int next[100] = {0};
		len = getnext(s2,next);
		i = 0;
		len1 = s1.size();
		len2 = s2.size();
		while( j<len2&&i<len1 ){
			if( s1[i]==s2[j]||j==-1 ){
				i++;
				j++;
			}else{
				j = next[j];
			}
		}
		if( i==len1 ){
			cout<<"not find!"<<endl;
		}else{
			cout<<i-len2<<endl;
		}
	}
} 
int getnext( string s,int next[] ){
	int i,j,k=-1;
	i = j = 0;
	next[0] = -1;
	while( j<s.size()-1 ){
		if( k==-1||s[k]==s[j] )
			next[++j] = ++k;
		else k = next[k];
	}
	return j;
}
